// StopBattLineSvc.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <service.h>

extern "C" { DWORD SetProcPermissions(DWORD newperms); }

int _tmain(int argc, _TCHAR* argv[])
{
  if (MessageBox(0, L"Stopping BattLineSvc may affect the ability of other 3rd party taskbar applications (Q-Menu, X-Button, WisBar, etc.) to respond to TaskBar events until a soft reset is performed. Do you want to continue?", L"Stop BattLineSvc", MB_YESNO) == IDYES)
  {
    SetProcPermissions(0xFFFFFFFF);

    HANDLE hsvc = GetServiceHandle(_T("BLS0:"), NULL, 0);
    if (hsvc != 0)
    {
      if (DeregisterService(hsvc))
      {
        MessageBox(0, L"BattLineSvc successfully stopped.", L"BattLineSvc", MB_TOPMOST);
        return 1;
      }
    }
  }

  MessageBox(0, L"Could not stop BattLineSvc.  Is it running?  If so, try soft resetting.", L"BattLineSvc", MB_TOPMOST);
  return 0;
}

